﻿/*****************************************************
 * 这个类继承自DraggableWidget                         *
 * 这个类添加了自定义标题栏，并且添加了正常的窗口应有的功能， *
 * 新创建的窗口均可继承自此类                            *
 * 若要修改标题栏，请到对应的类中自行修改                  *
 *****************************************************/

#pragma once

#include "WindowTitleBar.h"
#include "DraggableWidget.h"

#include <QWidget>
#include <QVBoxLayout>
#include <QSize>

class DraggableWindow : public DraggableWidget
{
    Q_OBJECT

public:
    explicit DraggableWindow(QWidget *parent = Q_NULLPTR);
    ~DraggableWindow();

protected:
    virtual void mouseMoveEvent(QMouseEvent *event);

public slots:
    QWidget *windowTitleBar() const;
    void setMainWidget(QWidget *m_widget);
    void moveWindowToDesktopCenter();
    void onIconButtonClicked();
    void onMinimizeButtonClicked();
    void onMaximizeButtonClicked();
    void onCloseButtonClicked();

private slots:
    void onHeaderPressed();
    void onHeaderReleased();
    void onInitialize();

private:
    QSize m_sRestoreSize;
    bool m_bHeaderPressed;
    WindowTitleBar *m_pTitleBar;
    QVBoxLayout *m_pWindowMainLayout;
};
